<%@ Page Language="C#" AutoEventWireup="true" Inherits="Soveryn.Commerce.Pages.OrderCheckout"
    MasterPageFile="~/Dummy.master" CodeFile="OrderCheckout.aspx.cs" %>

<%@ Register TagName="Cart" TagPrefix="sov" Src="~/Controls/CartControl.ascx" %>
<%@ Register TagName="Order" TagPrefix="sov" Src="~/Controls/OrderDetails.ascx" %>
<asp:Content ID="PageContent" ContentPlaceHolderID="PageContentPlaceHolder" runat="server">
    
    <script type="text/javascript">

        function orderButtonClick() {

            if (typeof (Page_ClientValidate) == 'function') {
                Page_ClientValidate();
                if (Page_IsValid) {
                    $("#<%= OrderAddButton.ClientID %>").css("display", "none");
                    $("#orderProcessingImage").css("display", "inline-block");
                }
            }

        }

        

    </script>

    <sov:Cart ID="CartControl" runat="server" Visible="false" />
    <sov:Order ID="OrderControl" runat="server" Visible="false" />
    <asp:UpdatePanel ID="CreditCardUpdatePanel" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel ID="PaymentPanel" runat="server">
                <div class="paymentResponse">
                    <asp:Label ID="PaymentResponseLabel" runat="server" Visible="false"></asp:Label>
                </div>
                <div class="orderPageContent">
                    <asp:HiddenField ID="OrderIDHdn" Visible="true" runat="server" />
                    <table style="margin-left: auto; margin-right: auto;">
                        <tr>
                            <td>
                                Payment Method:
                            </td>
                            <td>
                                <asp:DropDownList ID="PaymentMethodDropDown" runat="server" AppendDataBoundItems="true"
                                    ValidationGroup="PaymentInfo" AutoPostBack="true" OnSelectedIndexChanged="PaymentMethodDropDown_SelectedIndexChanged">
                                    <asp:ListItem Value="">Select ...</asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="PaymentMethodDropDownValidator" Display="dynamic"
                                    runat="server" ControlToValidate="PaymentMethodDropDown" ErrorMessage="Method Required"
                                    SetFocusOnError="true" ValidationGroup="PaymentInfo"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                    </table>
                    <div class="separator" style="margin-bottom: 10px; margin-top: 10px; width: 500px;
                        margin-left: auto; margin-right: auto;">
                    </div>
                    <asp:Panel ID="CreditCardInformationPanel" runat="server">
                        <table style="margin-left: auto; margin-right: auto;">
                            <tr>
                                <td style="text-align: right;">
                                    <asp:Label ID="PayCCNameLabel" runat="server" Text="Name on Card:"></asp:Label>&nbsp;&nbsp;&nbsp
                                </td>
                                <td style="text-align: left;">
                                    <asp:TextBox ID="PayCCNameTextBox" runat="server" ValidationGroup="PaymentInfo" Width="150px"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:RequiredFieldValidator ID="PayCCNameValidator" ControlToValidate="PayCCNameTextBox"
                                        Display="dynamic" ErrorMessage="Name Required" SetFocusOnError="true" runat="server"
                                        ValidationGroup="PaymentInfo"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right;">
                                    <asp:Label ID="PayCCNumberLabel" runat="server" Text="Card Number:"></asp:Label>&nbsp;&nbsp;&nbsp;
                                </td>
                                <td style="text-align: left;">
                                    <asp:TextBox ID="PayCCNumberTextBox" runat="server" MaxLength="19" ValidationGroup="PaymentInfo"
                                        Width="150px" autoComplete="Off"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:RequiredFieldValidator ID="PayCCNumberValidator" ControlToValidate="PayCCNumberTextBox"
                                        Display="dynamic" ErrorMessage="Card Number Required" SetFocusOnError="true"
                                        runat="server" ValidationGroup="PaymentInfo"></asp:RequiredFieldValidator>
                                    <asp:RangeValidator ID="RangeValidator2" runat="server" MinimumValue="0" MaximumValue="9999999999999999999"
                                        Display="dynamic" ErrorMessage="Invalid Credit Card Number" ControlToValidate="PayCCNumberTextBox"
                                        ValidationGroup="PaymentInfo"></asp:RangeValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right;">
                                    <asp:Label ID="PayCCVerificationNumberLabel" runat="server" Text="Verification Number:" />&nbsp;&nbsp;&nbsp;
                                </td>
                                <td style="text-align: left;">
                                    <asp:TextBox ID="PayCCVerificationNumberTextBox" Columns="4" MaxLength="4" runat="server"
                                        ValidationGroup="PaymentInfo"></asp:TextBox>
                                    &nbsp;&nbsp;
                                </td>
                                <td>
                                    <asp:RequiredFieldValidator ID="PayCCVerificationNumberValidator" runat="server"
                                        ControlToValidate="PayCCVerificationNumberTextBox" Display="dynamic" ErrorMessage="Verification Required"
                                        SetFocusOnError="true" ValidationGroup="PaymentInfo"></asp:RequiredFieldValidator>
                                    <asp:RangeValidator ID="PayCCVerificationNumberRangeValidator" runat="server" Type="Integer"
                                        MinimumValue="0" MaximumValue="9999999" Display="dynamic" ErrorMessage="Invalid Verification Number"
                                        ControlToValidate="PayCCVerificationNumberTextBox" ValidationGroup="PaymentInfo"></asp:RangeValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: right;">
                                    <asp:Label ID="PayCCExpireLabel" runat="server" Text="Expiration:"></asp:Label>&nbsp;&nbsp;&nbsp;
                                </td>
                                <td style="text-align: left;">
                                    <asp:DropDownList ID="PayCCExpireMonthDropDown" runat="server" ValidationGroup="PaymentInfo">
                                        <asp:ListItem Value="">Month</asp:ListItem>
                                        <asp:ListItem Value="01"></asp:ListItem>
                                        <asp:ListItem Value="02"></asp:ListItem>
                                        <asp:ListItem Value="03"></asp:ListItem>
                                        <asp:ListItem Value="04"></asp:ListItem>
                                        <asp:ListItem Value="05"></asp:ListItem>
                                        <asp:ListItem Value="06"></asp:ListItem>
                                        <asp:ListItem Value="07"></asp:ListItem>
                                        <asp:ListItem Value="08"></asp:ListItem>
                                        <asp:ListItem Value="09"></asp:ListItem>
                                        <asp:ListItem Value="10"></asp:ListItem>
                                        <asp:ListItem Value="11"></asp:ListItem>
                                        <asp:ListItem Value="12"></asp:ListItem>
                                    </asp:DropDownList>
                                    <asp:DropDownList ID="PayCCExpireYearDropDown" runat="server" ValidationGroup="PaymentInfo">
                                        <asp:ListItem Value="">Year</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                                <td>
                                    <asp:RequiredFieldValidator ID="PayCCExpireMonthDropDownValidator" runat="server"
                                        ControlToValidate="PayCCExpireMonthDropDown" Display="dynamic" ErrorMessage="Month Required"
                                        SetFocusOnError="true" ValidationGroup="PaymentInfo"></asp:RequiredFieldValidator>
                                    <asp:RequiredFieldValidator ID="PayCCExpireYearDropDownValidator" runat="server"
                                        ControlToValidate="PayCCExpireYearDropDown" Display="dynamic" ErrorMessage="Year Required"
                                        SetFocusOnError="true" ValidationGroup="PaymentInfo"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <asp:Panel ID="POInstructionTable" Visible="false" runat="server">
                        <table class="fieldTable">
                            <tr>
                                <td>
                                    <asp:Label ID="OrderPONumberLabel" runat="server" Text="PO #:" Visible="True">
                                    </asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="OrderPONumberTextBox" runat="server" Visible="True">
                                    </asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="OrderInstructionslabel" runat="server" Text="Instructions:" Visible="True">
                                    </asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="OrderInstructionsTextBox" Columns="25" MaxLength="500" TextMode="MultiLine"
                                        runat="server" Visible="True">
                                    </asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <div style="text-align: center;margin:20px;">
                        <div id="orderProcessingImage" class="orderProcessingImage" style="display:none;"></div>
                        <asp:LinkButton ID="OrderAddButton" Text="Place order" CssClass="buttonPositive"
                            runat="server" OnClick="OrderAddButton_Click" ValidationGroup="PaymentInfo" OnClientClick="orderButtonClick();" />
                    </div>
                    Discount* - manufacturer rebate. State/Prov taxes apply to full price.
                </div>
            </asp:Panel>
            <asp:Label ID="LocationErrorLabel" runat="server" Style="font-size: 1.2em;" Visible="false"
                Text="There is a problem with your address; please contact customer service." />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
